package com.jtny.nytb.datafilling.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.jtny.component.entity.PageData;
import com.jtny.component.entity.PageParam;
import com.jtny.component.entity.WebResponse;
import com.jtny.nytb.datafilling.domain.InsertUserEletricParamVO;
import com.jtny.nytb.datafilling.service.UserElectircService;
import com.jtny.nytb.datafilling.dto.DatafillingUserelectircFillDTO;
import com.jtny.nytb.datafilling.vo.UserEletricParamVO;
import com.jtny.nytb.datafilling.vo.UserelectricEquipmentVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.schema.property.ObjectMapperBeanPropertyNamingStrategy;

import java.util.List;

/**
 * 能源价格配置填报Controller类
 *
 * @author 智慧能源中心-罗霄林
 * @version 1.0
 * @package com.jtny.nytb.energymonitor.datafilling.controller
 * @fileName EnergyPriceConfigController.java
 * @createTime 2023年09月04日 16:13
 * @Copyright© 2023 jtny
 * 江投能源技术研究院 版权所有
 */
@RestController
@Api(value = "用户用电信息填报", tags = "用户用电信息填报")
public class UserEletricController {

    @Autowired
    private UserElectircService userElectircService;
    @Autowired
    private ObjectMapperBeanPropertyNamingStrategy objectMapperBeanPropertyNamingStrategy;

    @ApiOperation("新版新增用户用电信息")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParam(name = "userEletricParamVO", value = "用户用电信息填报", required = true, paramType = "query", dataType = "userEletricParamVO")
    @PostMapping("/addUserEletricInfo")
    @ResponseBody
    WebResponse<Boolean> addUserEletricInfo(@RequestBody UserEletricParamVO userEletricParamVO) {
        return WebResponse.success(userElectircService.addUserEletricInfo(userEletricParamVO));
    }

    @ApiOperation("用户用电信息保存")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParam(name = "userEletricParamVO", value = "用户用电信息填报", required = true, paramType = "query", dataType = "userEletricParamVO")
    @PostMapping("/saveUserEletricInfo")
    @ResponseBody
    WebResponse<Boolean> saveUserEletricInfo(@RequestBody UserEletricParamVO userEletricParamVO) {
        return WebResponse.success(userElectircService.saveUserEletricInfo(userEletricParamVO));
    }

    @ApiOperation("用户用电信息分页查询")
    @ApiOperationSupport(order = 2)
    @PostMapping("/queryUserEletricInfoPage")
    @ResponseBody
    WebResponse<PageData<DatafillingUserelectircFillDTO>> queryPage(@RequestBody PageParam pageParam) {
        return WebResponse.success(userElectircService.queryPage(pageParam));
    }

    @ApiOperation("功率因数等级查询（除去0.90、0.85、0.80）")
    @ApiOperationSupport(order = 3)
    @PostMapping("/queryPowerFactor")
    @ResponseBody
    WebResponse<List<String>> queryPowerFactor() {
        return WebResponse.success(userElectircService.queryPowerFactor());
    }

    @ApiOperation("旧版新增用户用电信息")
    @ApiOperationSupport(order = 4)
    @PostMapping("/insertUserEletricInfo")
    @ResponseBody
    WebResponse<?> insertUserEletricInfo(@RequestBody InsertUserEletricParamVO insertUserEletricParamVO) {
        return WebResponse.success(userElectircService.insertUserEletricInfo(insertUserEletricParamVO));
    }

    @ApiOperation("删除用户用电信息")
    @ApiOperationSupport(order = 5)
    @GetMapping("/delUserEletricInfo/{id}")
    @ResponseBody
    WebResponse<?> delUserEletricInfo(@PathVariable("id") String id) {
        userElectircService.delUserEletricInfo(id);
        return WebResponse.success();
    }

    @ApiOperation("保存制度和设备的关系")
    @ApiOperationSupport(order = 6)
    @PostMapping("/saveOrUpdateElectricModelRealtion")
    public WebResponse<?> saveOrUpdateRealtion(@RequestBody List<UserelectricEquipmentVO> list){
        userElectircService.saveOrUpdateRealtion(list);
        return WebResponse.success();
    }

    @ApiOperation("查询制度和设备的关系")
    @ApiOperationSupport(order = 7)
    @GetMapping("/getUserElectricModelEquipment/{id}")
    public WebResponse<?> getUserelectricEquipment(@PathVariable Long id){
        return WebResponse.success(userElectircService.getUserelectricEquipment(id));
    }

    @ApiOperation("删除制度和设备的关系")
    @ApiOperationSupport(order = 8)
    @PostMapping("/removeElectricModelRelation")
    public WebResponse<?> removeRelation(@RequestBody List<UserelectricEquipmentVO> objects){
        userElectircService.removeRelation(objects);
        return WebResponse.success();
    }




}
